﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace 时钟壁纸应用
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
            //UI线程异常
            this.DispatcherUnhandledException += App_DispatcherUnhandledException;
            //非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
        }
        private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            //可以记录日志并转向错误bug窗口友好提示用户
            e.Handled = true;
            MessageBox.Show($"程序UI线珵遇到异常{e.Exception.Message}", "异常抛出");

        }
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            //可以记录日志并转向错误bug窗口友好提示用户
            if (e.ExceptionObject is System.Exception)
            {

                Exception ex = (System.Exception)e.ExceptionObject;

                MessageBox.Show($"程序主线珵遇到异常{e.ExceptionObject.ToString()}", "异常抛出");
            }
        }

    }
}
